from textitem import TextFormItem
from relativelayout import HorizontallyFixedRelativeLayout
from dynamicposition import FormHeight
from dynamicposition import FormWidth
from dynamicposition import DynamicPosition
from dynamicposition import LeftScreenEdge
from button import BasicTextButton
from ..background import VerticalGradientWithLowerBorderBackground
from . import Form

class SimpleHeader(Form):
  def __init__(self, screen, title, left_buttons=[], right_buttons=[],
      top_color='#CAD5E0', bottom_color='#6B8AA9'):
    text_attrs = {
      "fg_color": "#FFFFFF",
      "bg_color": None,
      "size": 22,
      "weight": TextFormItem.WEIGHT_BOLD,
    }
    title = TextFormItem(screen, title, text_attrs)
    layout = HorizontallyFixedRelativeLayout(800)
    dp = DynamicPosition(title, hcenter=FormWidth(layout),
        vcenter=FormHeight(layout), vspacing=(5, 5))
    layout.AddItem(dp)

    prev = LeftScreenEdge()
    for button in left_buttons:
      dp = DynamicPosition(button, vcenter=FormHeight(layout), right_of=prev,
          hspacing=(5, 0), vspacing=(5, 5))
      layout.AddItem(dp)
      prev = dp

    Form.__init__(self, 0, 0, layout,
        VerticalGradientWithLowerBorderBackground(top_color, bottom_color))

